| Conditions | 5 | 
| Total Lines | 52 | 
| Code Lines | 45 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import React, { Component, Fragment } from "react" | ||
| 44 | |||
| 45 |   render() { | ||
| 46 |     if (this.state.loading === false && this.state.data) { | ||
| 47 | this.state.data.sort((a, b) => a.dateTime - b.dateTime) | ||
| 48 | |||
| 49 |       if (this.state.data.length <= 0) { | ||
| 50 | return ( | ||
| 51 | <div className="matches_overview__wrapper"> | ||
| 52 | Geen wedstrijden gevonden. | ||
| 53 | </div> | ||
| 54 | ) | ||
| 55 | } | ||
| 56 | |||
| 57 |       moment.locale("nl-be") | ||
| 58 | let matchTime = moment() | ||
| 59 | |||
| 60 | const ignore = this.props.exclude || [] | ||
| 61 | |||
| 62 | return ( | ||
| 63 | <div className="matches_overview__wrapper"> | ||
| 64 |           {this.state.data.map((match, i) => { | ||
| 65 |             if (ignore.includes(match.division)) { | ||
| 66 |               return <Fragment key={i} /> | ||
| 67 | } | ||
| 68 | |||
| 69 | matchTime = moment(match.dateTime) | ||
| 70 | return ( | ||
| 71 |               <div key={i}> | ||
| 72 |                 <span className={"label"}> | ||
| 73 |                   {formatDivision(match.division, match.region)} | ||
| 74 | </span> | ||
| 75 |                 <span className={"matches_overview__date"}> | ||
| 76 |                   {matchTime.format("ddd D MMMM - H:mm")} | ||
| 77 | </span> | ||
| 78 | |||
| 79 |                 {match.status ? ( | ||
| 80 |                   <span className={"label alert matches_overview__status"}> | ||
| 81 |                     {mapMatchStatus(match.status)} | ||
| 82 | </span> | ||
| 83 | ) : ( | ||
| 84 | "" | ||
| 85 | )} | ||
| 86 | <h6> | ||
| 87 |                   {match.home} - {match.away} | ||
| 88 | </h6> | ||
| 89 | </div> | ||
| 90 | ) | ||
| 91 | })} | ||
| 92 | </div> | ||
| 93 | ) | ||
| 94 |     } else { | ||
| 95 | return <div>Loading...</div> | ||
| 96 | } | ||
| 124 |